<template>
  <section class="jumbotron">
    <h3 class="jumbotron-heading">Search Github Users</h3>
    <div>
      <input
        type="text"
        placeholder="enter the name you search"
        v-model="keyWord"
      />&nbsp;
      <button @click="search">Search</button>
    </div>
  </section>
</template>

<script>
import axios from 'axios';
export default {
    data() {
        return {
            keyWord:'',
        }
    },
    methods: {
        async search(){
            try {
                const response = await axios.get('https://api.github.com/search/users',{params:{q:this.keyWord}});
                const {items} = response.data;
                //传递给list
                this.$bus.$emit('get-data-from-search',items);
            } catch (error) {
                console.log(error.message);
            }
        }
    },
};
</script>

<style>
</style>